package com.aster.service.manage.service.impl;

import com.aster.common.base.BaseServiceImpl;
import com.aster.common.dto.UserToken;
import com.aster.common.exception.ServiceException;
import com.aster.service.manage.dao.CommissionRatioInfoDao;
import com.aster.service.manage.domain.TbCommissionRatioInfo;
import com.aster.service.manage.domain.TbEnterpriseProfitRatioInfo;
import com.aster.service.manage.service.CommissionRatioInfoService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 
 * <br>
 * <b>功能：</b>TbCommissionRatioInfoService<br>
 */
@Service("commissionRatioInfoService")
public class  CommissionRatioInfoServiceImpl  extends BaseServiceImpl implements CommissionRatioInfoService {
  private final static Logger log= Logger.getLogger(CommissionRatioInfoServiceImpl.class);
	

	@Autowired
    private CommissionRatioInfoDao dao;

		
	public CommissionRatioInfoDao getDao() {
		return dao;
	}


	@Override
	public void addCommissionRatioInfo(TbCommissionRatioInfo tbCommissionRatioInfo, UserToken userToken) throws ServiceException {
		if (tbCommissionRatioInfo == null){
			throw new ServiceException(10001,"参数为空");
		}
		try {
			tbCommissionRatioInfo.setCreateTime(new Date());
			tbCommissionRatioInfo.setUpdateTime(new Date());
			tbCommissionRatioInfo.setCreateUserId(Integer.parseInt(userToken.getUserId()));
			tbCommissionRatioInfo.setUpdateUserId(Integer.parseInt(userToken.getUserId()));
			tbCommissionRatioInfo.setState(0);
			tbCommissionRatioInfo.setDeleted(1);
			dao.add(tbCommissionRatioInfo);

		}catch (Exception ex){
			throw new ServiceException(10000,ex.getMessage());
		}
	}

	@Override
	public TbCommissionRatioInfo queryByEscortUserIdAndState(Object escortUserId) {
		return dao.queryByEscortUserIdAndState(escortUserId);
	}
}
